//
//  ProjectDefine.h
//  WiFiProject
//
//  Created by JianWei Chen on 17/2/6.
//  Copyright © 2017年 JianWei Chen. All rights reserved.
//

/*
 系统全局宏调用
 需要全局多个地方调用的宏整理到这里
 */

#ifndef ProjectDefine_h
#define ProjectDefine_h
#ifdef __OBJC__
/*
 常见并经常使用的宏
 */
#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height
#define GetViewWidth(view)    view.frame.size.width
#define GetViewHeight(view)   view.frame.size.height
#define GetViewX(view)        view.frame.origin.x
#define GetViewY(view)        view.frame.origin.y
#define StatusbarHeight       (20.f)
#define NavigationbarHeight   (44.f)
#define TabBarHeight          (49.f)
#define MAIN(block) dispatch_async(dispatch_get_main_queue(),block) //主函数调用

//NSUserDefaults
#define SAVE_OBJECT(object,key) {[[NSUserDefaults standardUserDefaults] setObject:object forKey:key] ; [[NSUserDefaults standardUserDefaults]synchronize];}
#define SAVE_BOOL(value,key) {[[NSUserDefaults standardUserDefaults] setBool:value forKey:key] ; [[NSUserDefaults standardUserDefaults]synchronize];}
#define EXRACT_OBJECT(key)        [[NSUserDefaults standardUserDefaults] objectForKey:key]
#define EXRACT_BOOL(key) [[NSUserDefaults standardUserDefaults]boolForKey:key]
#define REMOVE_OBJECT(key)   [[NSUserDefaults standardUserDefaults]removeObjectForKey:key]
#define PorPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",EXRACT_OBJECT(USERNAME)]]
#define PorImage(key) [UIImage imageWithContentsOfFile:key]
#define kDocument  NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]
#define ConfigPath [kDocument stringByAppendingPathComponent:@"deviceconfig.plist"]
#define CommandDic(type) [kDocument stringByAppendingPathComponent:[NSString stringWithFormat:@"product/%@/config/device.json",type]]
#define PicPath(type) [kDocument stringByAppendingPathComponent:[NSString stringWithFormat:@"product/%@",type]]

#define px1920Height(px)     (((px)/1920.0f) * SCREEN_HEIGHT)
#define px1080Width(px)     (((px)/1080.0f) * SCREEN_WIDTH)
#define colorWithAlpha(r, g, b, a) [UIColor colorWithRed:(r) / 255.0 green:(g) / 255.0 blue:(b) / 255.0 alpha:(a)]
#define imageWithName(image) [UIImage imageNamed:image]
#define fontWithSize(size) [UIFont systemFontOfSize:size]


/*
 网络库常用宏
 */
#define SEX @"SEX"          //判断是否选择性别
#define ICON @"ICON"
#define UID @"UID"
#define TOKEN @"TOKEN"
#define IMAGE @"IMAGE"
#define INFODIC @"INFODIC"
#define NEWSCOUNT @"NEWSCOUNT"
#define DEVICEMAC @"DEVICEMAC"
#define DEVICEID @"DEVICEID"
#define NICKNAME @"NICKNAME"
#define USERNAME @"USERNAME"    //将登录帐号存储到UserDefault时用
#define PASSWORD @"PASSWORD"    //将登录密码存储到UserDefault时用
#define LOGIN @"LOGIN"          //判断是否登录过
#define VERSION @"1.0"          //版本
#define MAC   [UIDevice currentDevice].identifierForVendor.UUIDString
#define BraceletRadiationLimit @"BraceletRadiationLimit"
#define BraceletSleepTarget @"BraceletSleepTarget"
#define BraceletSportTarget @"BraceletSportTarget"
#define RadiateAlarm @"RadiateAlarm"
#define CallRemind @"CallRemind"
#define MessageRemind @"MessageRemind"

/*
 正测环境切换
 */
#define SanBox 1
#if SanBox

#define AppSanBox YES
#define kMQTTServerHost @""
#define ServerURL @"http://120.24.55.58:8042/index.php/"
#define TYPEID @"2288"
#define DTCloudKitAppId @"50133"
#define DTCloudKitAppKey @"4F8158D45202DD32EE8B7625275EAEDC"

#else

#define AppSanBox NO
#define kMQTTServerHost @""
#define ServerURL @""
#define TYPEID @""
#define DTCloudKitAppId @""
#define DTCloudKitAppKey @""

#endif







/*
 项目使用宏，注意顺序别乱
 */


#endif
#endif /* ProjectDefine_h */

#ifdef DLOG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt),__PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(...)
#endif
